<template>
  <div>
    <div class="box-title" >办单箱公司设置</div>
    <el-transfer 
    filterable 
    v-model="list1" 
    :data="list" 
    :titles="['箱公司名称','办单箱公司']" 
    :props="props"></el-transfer>
    <div class="btn">
        <el-button type="primary"
                   size="small"
                   style="background-color:transparent;color: #043AA7;"
                   @click="$emit('close')">取消</el-button>
        <el-button type="primary"
                   size="small"
                   :loading="butLoading"
                   style="background-color:#043AA7"
                   @click="save">保存</el-button>
    </div>
  </div>
</template>

<script>
import moment from 'moment'
export default {
  name: '',
  components: {},
  props:{
    see:false,
    data:[],
    data1:[]
  },
 
  watch:{
    data(){
      this.$forceUpdate()
    },
    data1(){
      this.$forceUpdate()
    }
  },
  data() {
    return { 
      list:JSON.parse(JSON.stringify(this.data)),
      list1:JSON.parse(JSON.stringify(this.data1)).map(x=>x.relationTenantId),
      butLoading:false,
      props:{
        key: 'customerCode',
        label: 'name'
      }
    }
  },
  watch:{
    data(){
      this.list=JSON.parse(JSON.stringify(this.data))
    },
    data1(){
      this.list1=JSON.parse(JSON.stringify(this.data1)).map(x=>x.relationTenantId)
    },
  },
  methods: {
    clear(){
      this.list=[]
      this.list1=[]
      this.$emit('close')
    },
    save(){
      this.butLoading=true
      let that = this
      this.$api.setRelation(that.list1).then(res=>{
        if(200===res.code){
          this.$message({
            message: '修改办单箱公司成功！',
            type:'success',
            onClose(){
              that.clear()
            }
          });
          
        }else{
          this.butLoading=false
        }
      }).catch(res=>{
        this.butLoading=false
      })
    },
  },

  computed: {},

  mounted() {
    //this.init()
  },
}
</script>
<style lang='less' scoped>
.form{
  display: flex;
  justify-content: center;
  width: 100%;
}
.box-title {
  font-size: 18px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #333333;
  line-height: 16px;
  line-height: 20px;
  padding-left: 10px;
  border-left: 5px solid #4980d5;
  margin-bottom: 20px;
}
.btn {
  margin-top: 30px;
  padding-bottom: 10px;
  border-bottom: 1px solid #d7d7d7;
  display: flex;
  justify-content: flex-end;
  .el-button {
    width: 80px;
    margin-right: 30px;
  }
}
</style>
